<html>
	<head>
		<title>Carnegie FS | Transaction History</title>
		#{include 'html_head.html'/}
	</head>

	<body>
		<div id="container">
			<!-- Page Header -->
			#{include 'header.html'/}
	
			<!-- Content Area -->
			<div id="content">
				<a href="portfolio"><< Back to Portfolio</a>
				<div class="title">Your Transaction History</div>				
				<table width="100%">
					<tr>
						<td class="profile_item_lbl">Account Holder</td>
						<td class="profile_item_value">${customer.firstname} ${customer.lastname}</td>
					</tr>
					<tr>
						<td class="profile_item_lbl">Available Balance</td>
						<td class="profile_item_value">USD ${availableBalance}</td>
					</tr>
					<tr>
						<td class="profile_item_lbl">Ledger Balance</td>
						<td class="profile_item_value">USD ${customer.cash}</td>
					</tr>
				</table>
				
				<div class="clear"></div>
				
				%{ int count = 0; }%
				
				<table>
					<tr>
						<th class="tbl_header">Date</th>
						<th class="tbl_header">Operation</th>
						<th class="tbl_header">Fund</th>
						<th class="tbl_header">No of Shares</th>
						<th class="tbl_header">Price</th>
						<th class="tbl_header">Amount</th>
					</tr>
					
					#{list items:pending, as:'pending_item'}
					<tr>
						<td class="tbl_row"><i><font color="#777">Pending...</font></i></td>
						<td class="tbl_row"><i><font color="#777">${pending_item.transaction_type}</font></i></td>
						<td class="tbl_row"><i><font color="#777">%{if(pending_item.transaction_type.equalsIgnoreCase("buy") || pending_item.transaction_type.equalsIgnoreCase("sell")){}% ${pending_item.position.fund.symbol} %{}}%</font></i></td>
						<td class="tbl_row right_aligned"><i><font color="#777">%{if(pending_item.shares!=null){}% ${pending_item.shares.format('#,##0.000')} %{if(pending_item.transaction_type.equalsIgnoreCase("buy")){}%*%{}}}%</font></i></td>
						<td class="tbl_row right_aligned"><i><font color="#777">%{if(prices.get(count)!=null && (pending_item.transaction_type.equalsIgnoreCase("buy") || pending_item.transaction_type.equalsIgnoreCase("sell"))){}% ${prices.get(count).format('#,##0.00')}* %{}}%</font></i></td>
						<td class="tbl_row right_aligned"><i><font color="#777">USD ${pending_item.amount.format('#,##0.00')}%{if(pending_item.transaction_type.equalsIgnoreCase("sell")){}%*%{}}%</font></i></td>
					</tr>
					%{ count++; }%
					#{/list}
					
					#{list items:executed, as:'executed_item'}
					<tr>
						<td class="tbl_row">${executed_item.execute_date.format()}</td>
						<td class="tbl_row">${executed_item.transaction_type}</td>
						<td class="tbl_row">%{if(executed_item.position!=null){}% ${executed_item.position.fund.symbol} %{}}%</td>
						<td class="tbl_row right_aligned">%{if(executed_item.shares!=null){}% ${executed_item.shares.format('#,##0.000')} %{}}%</td>
						<td class="tbl_row right_aligned">%{if(executed_item.shares!=null){}% ${(executed_item.amount/executed_item.shares).format('#,##0.00')} %{}}%</td>
						<td class="tbl_row right_aligned">USD ${executed_item.amount.format('#,##0.00')}</td>
					</tr>
					#{/list}
				</table>
				Values marked with asterisk (*) indicate tentative amount; actual value transacted may differ.
			</div>
			
			<!-- Page Footer -->
			#{include 'footer.html'/}
		</div>
	</body>

</html>		